﻿#region License
// (c) Intergen.
// This source is subject to the Microsoft Public License (Ms-PL).
// Please see http://go.microsoft.com/fwlink/?LinkID=131993 for details.
// All other rights reserved.
#endregion

using System;
using TextGlow.Control.Utilities;

namespace TextGlow.Control.Model
{
  public static class ModelUtils
  {
    public static Unit? ToUnit(int? value, string type)
    {
      if (type == null)
        return null;

      switch (type)
      {
        case "dxa":
          return Unit.Twip(value);
        case "pct":
          return Unit.Percent(value / (double)5000);
        default:
          throw new ArgumentNullException("type");
      }
    }
  }
}
